package com.example.demo.day0222;

public class Order {
    int orderId;
    String orderName;
    public Order(int orderId,String orderName) {//创建一个含上面两个参数的构造器
        this.orderId = orderId;
        this.orderName = orderName;
    }

    public int getOrderId() {
        return orderId;
    }

    public void setOrderId(int orderId) {
        this.orderId = orderId;
    }

    public String getOrderName() {
        return orderName;
    }

    public void setOrderName(String orderName) {
        this.orderName = orderName;
    }

    @Override
    public boolean equals(Object obj) {//重写equal方法
        boolean h1=false;//创建一个boolean类型的值
        if (obj instanceof Order ){//判断obj是否为Order中的对象，并返回一个boolean类型的值
            Order o=(Order) obj;//将obj的类型强制转换后赋给Order的对象o
            if (this.orderId==o.orderId&&this.orderName.equals(o.orderName)){
                h1=true;

            }
        }
        return h1;
    }

}
